package com.jqkb.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fasterxml.jackson.databind.JsonNode;
import com.jqkb.R;

/**
 * Created by alimjantursun on 18/5/29.
 */
public class HistoryAdapter extends RecyclerView.Adapter {
    private final JsonNode node;
    private final Context context;

    public HistoryAdapter(Context context, JsonNode node) {
        this.context = context;
        this.node = node;
    }





    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.his_list_item, parent, false);
        return new ClassHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
            ((ClassHolder) holder).timeTv.setText(node.get(position).path("date").asText());
            ((ClassHolder) holder).chulirenTv.setText(node.get(position).path("user").path("name").asText());
            ((ClassHolder) holder).yijianTv.setText(node.get(position).path("fillContent").asText());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


            }
        });

    }

    public class ClassHolder extends RecyclerView.ViewHolder {


        TextView timeTv;
        TextView chulirenTv;
        TextView yijianTv;

        public ClassHolder(View itemView) {
            super(itemView);
            timeTv = (TextView) itemView.findViewById(R.id.timeTv);
            chulirenTv = (TextView) itemView.findViewById(R.id.chulirenTv);
            yijianTv = (TextView) itemView.findViewById(R.id.yijianTv);

        }
    }

    @Override
    public int getItemCount() {
        return node.size();
    }




}
